package graduate.wangyaqi.ProgrammeQuestions;

import graduate.wangyaqi.FillingQuestions.FillingQuestions;
import graduate.wangyaqi.OnlyQuestions.OnlyQuestions;
import graduate.wangyaqi.OnlyQuestions.OnlyQuestionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.Optional;

@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping(path="/ProgrammerQuestions")
public class ProgrammeQuestionsController {
    @Autowired
    private ProgrammeQuestionsService programmeQuestionsService;

    @GetMapping(path="/getAllByTaotiID")
    public Iterable<ProgrammeQuestions> getAllByTaotiID(int id){
        Iterable<ProgrammeQuestions> programmeQuestions = programmeQuestionsService.getAllByTaotiID(id);
        return programmeQuestions;
    }

    @GetMapping(path="/delete")
    public @ResponseBody
    void Del(Long id) {
        programmeQuestionsService.delete(id);
    }

    @PostMapping(path="/save")
    public boolean save(@RequestBody ProgrammeQuestions programmeQuestions){
        programmeQuestions.setJointime(new Date());
        programmeQuestionsService.save(programmeQuestions);
        return true;
    }
    @GetMapping(path="/findById")
    public Optional<ProgrammeQuestions> findById(Long aLong){
        return programmeQuestionsService.findById(aLong);
    }

}
